package com.rz.admin.dubbo.service;

import com.alibaba.fastjson.JSONObject;
import com.rz.core.config.RedisKeys;
import com.rz.core.kit.RedisKit;
import consumer.DictService;
import consumer.model.SysDictData;
import org.apache.dubbo.config.annotation.Service;

import javax.annotation.Resource;

@Service(version = "1.0.0")
public class DictServiceImpl implements DictService {

    @Resource private RedisKit redisKit;

    @Override
    public SysDictData getByCode(String code) {
        Object dictDataObj = redisKit.getValueHash(RedisKeys.DICT_KEY,code);
        if(dictDataObj!=null){
            try{
                return JSONObject.parseObject(dictDataObj.toString(),SysDictData.class);
            }catch (Exception e){
                return null;
            }
        }else{
            return null;
        }
    }
}
